//////////////////////////////////////////////////////////////////////
// DeadTouch - third line of the legendary OpenTibia Server
//////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//////////////////////////////////////////////////////////////////////

#ifndef __MARKS_H__
#define __MARKS_H__

#include <vector>
#include <string.h>

#include "position.h"

class Mark
{
      public:
             Mark( std::string name, Position pos ) : markName(name), markPos(pos) {}
             
             std::string getName() const { return markName; }
             Position getPosition() const { return markPos; }
             
      protected:
             std::string markName;
             Position markPos;
};

typedef std::vector<Mark*> MarksVector;

class Marks
{
      public:
             bool loadFromXml( std::string filename );
             static Marks& getInstance()
             {
                    static Marks instance;
                    return instance;
             }
             
             MarksVector::const_iterator getMarksBegin() const { return v.begin(); }
             MarksVector::const_iterator getMarksEnd() const { return v.end(); }
             
             Mark* getMark( std::string name ) const
             {
                   for( MarksVector::const_iterator it = v.begin(); it != v.end(); ++it )
                   {
                        if( strcasecmp( (*it)->getName().c_str(), name.c_str() ) == 0 )
                            return (*it);
                   }
                   
                   return NULL;
             }
             
             void addMark( std::string name, PositionEx pos ) { v.push_back( new Mark( name, pos) ); }
             void addMark( Mark *m ) { v.push_back( m ); }
             
      protected:
             MarksVector v;             
};
#endif // __MARKS_H__

